package com.framework.modules.base.dao;

import com.framework.modules.base.entity.PostsEntity;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * 用户动态
 * 
 * @author MIT
 * @email litmiss@gmail.com
 * @date 2020-10-03 16:58:28
 */
public interface PostsDao extends BaseMapper<PostsEntity> {

    /**
     * 更新评论或喜欢或分享数
     * @return
     */
    Integer updatePostslcsCount(Integer id,Integer likeCount,Integer commentCount,Integer shareCount);

    /**
     * 更新评论喜欢数+1
     * @return
     */
    @Update("update tb_posts set like_count=like_count+1 where id=#{id}")
    Integer addPostsLikeCount(@Param("id") Integer id);

    /**
     * 更新评论喜欢数-1
     * @return
     */
    @Update("update tb_posts set like_count=like_count-1 where id=#{id}")
    Integer reducePostsLikeCount(@Param("id")Integer id);

    /**
     * 更新分享数+1
     * @return
     */
    @Update("update tb_posts set share_count=share_count+1 where id=#{id}")
    Integer addPostsShareCount(@Param("id")Integer id);

    /**
     * 更新分享数-1
     * @return
     */
    @Update("update tb_posts set share_count=share_count-1 where id=#{id}")
    Integer reducePostsShareCount(@Param("id")Integer id);

    /**
     * 更新评论数+1
     * @return
     */
    @Update("update tb_posts set comment_count=comment_count+1 where id=#{id}")
    Integer addPostsCommentCount(@Param("id")Integer id);

    /**
     * 更新评论数-1
     * @return
     */
    @Update("update tb_posts set comment_count=comment_count-1 where id=#{id}")
    Integer reducePostsCommentCount(@Param("id")Integer id);
	
}
